
using PEMath;


namespace PEPhysx
{
    public abstract class PEColliderBase
    {
        public string name;
        public PEVector3 mPos;

        public virtual bool DetectContact(PEColliderBase collider, ref PEVector3 normal, ref PEVector3 borderAdjust) {
            if(collider is PEBoxCollider boxCol) 
                return DetectBoxContact(boxCol, ref normal, ref borderAdjust);
            else if(collider is PECylinderCollider cylinderCol) 
                return DetectSphereContact(cylinderCol, ref normal, ref borderAdjust);
            else
            {
                //若有其他可补充
                return false;
            }
        }

        public abstract bool DetectSphereContact(PECylinderCollider col, ref PEVector3 normal,
            ref PEVector3 borderAdjust);

        public abstract bool DetectBoxContact(PEBoxCollider col, ref PEVector3 normal, ref PEVector3 borderAdjust);
    }

    public class CollisionInfo
    {
        public PEColliderBase collider;
        public PEVector3 normal;
        public PEVector3 borderAdjust;
    }
}

